'''
Created on Mar 10, 2013

@author: Petko
'''
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer, BINARY, String, Unicode
from sent.model.entities import EntBase, EntityWithUUID

class User(EntityWithUUID, EntBase):
    '''
    classdocs
    '''
    __tablename__ = 'User'
    id = Column(BINARY, primary_key=True)
    external_id = Column(Unicode)
    external_data = Column(Unicode)
    #rating = Column(Float)
    
    def toPrimitiveDict(self):
        result = {}
        result['id'] = self.external_id
        if self.external_data != None:
            result['data'] = self.external_data
        return result
        
class Permission(EntBase):
    __tablename__ = 'Permission'
    permission_id = Column(Integer, primary_key=True)
    permission_name = Column(String)
    
class Group(EntityWithUUID, EntBase):
    __tablename__ = 'UGroup'
    
    id = Column(BINARY, primary_key=True)
    external_id = Column(Unicode)
    external_data = Column(Unicode)

class GroupPermission(EntBase):
    __tablename__ = 'Group_Permissions'
    
    id = Column(BINARY, primary_key=True)
    permission_id = Column(Integer, primary_key=True)

class GroupBaseOpinionPermissions(EntBase):
    __tablename__ = 'Group_Base_Opinion_Permissions'
    
    permission_id = Column(Integer, primary_key=True)
    group_id = Column(BINARY, primary_key=True)
    opinion_id = Column(BINARY, primary_key=True)

class GroupViewPermissions(EntBase):
    __tablename__ = 'Group_View_Permissions'
    
    group_id = Column(BINARY, primary_key=True)
    permission_id = Column(Integer, primary_key=True)
    view_id = Column(BINARY, primary_key=True)
    
    
class UserGroup(EntBase):
    __tablename__ = 'User_Groups'
    
    user_id = Column(BINARY, primary_key=True)
    group_id = Column(BINARY, primary_key=True)
    
    
class Sequence_Generation(EntBase):
    __tablename__ = 'Sequence_Generation'
    dummy_uuid = Column(Integer, primary_key=True)